package com.itfenghuang.day13_练习;

import java.util.Comparator;
import java.util.HashSet;
import java.util.TreeSet;

public class A01_练习 {
    public static void main(String[] args) {
//        选择器排序();
//        hashSet去重();//关键字hashcode与equals方法

    }

    private static void hashSet去重() {
        HashSet<Object> hs = new HashSet<>();
        AAAA a = new AAAA("小坏蛋", 16, "男");
        AAAA a1 = new AAAA("大人物", 18, "女");
        AAAA a2 = new AAAA("臭狗屎", 17, "女");
        AAAA a3 = new AAAA("小坏蛋", 16, "男");
        hs.add(a);
        hs.add(a1);
        hs.add(a2);
        hs.add(a3);
        System.out.println(hs);
    }

    private static void 选择器排序() {
        TreeSet<Integer> set = new TreeSet<>(new Comparator<Integer>() {
            @Override
            public int compare(Integer o1, Integer o2) {
                int i=o1-o2;
                return i;
            }
        });
        set.add(19);
        set.add(20);
        set.add(17);
        set.add(21);
        set.add(13);
        System.out.println(set);
    }
}
